Imports Microsoft.VisualBasic

Public Class Product
    Inherits BaseEntity

    Private _ProductName As String
    Public Property ProductName() As String
        Get
            Return _ProductName
        End Get
        Set(ByVal value As String)
            _ProductName = value
        End Set
    End Property

    Private _ProductDescription As String
    Public Property ProductDescription() As String
        Get
            Return _ProductDescription
        End Get
        Set(ByVal value As String)
            _ProductDescription = value
        End Set
    End Property

    Private _Price As Double
    Public Property Price() As Double
        Get
            Return _Price
        End Get
        Set(ByVal value As Double)
            _Price = value
        End Set
    End Property

    Private _ProductTypeID As Short
    Public Property ProductTypeID() As Short
        Get
            Return _ProductTypeID
        End Get
        Set(ByVal value As Short)
            _ProductTypeID = value
        End Set
    End Property

    Private _CategoryGroupID As String
    Public Property CategoryGroupID() As String
        Get
            Return _CategoryGroupID
        End Get
        Set(ByVal value As String)
            _CategoryGroupID = value
        End Set
    End Property

    Private _CategoryID As String
    Public Property CategoryID() As String
        Get
            Return _CategoryID
        End Get
        Set(ByVal value As String)
            _CategoryID = value
        End Set
    End Property

    Private _ProductCode As String
    Public Property ProductCode() As String
        Get
            Return _ProductCode
        End Get
        Set(ByVal value As String)
            _ProductCode = value
        End Set
    End Property

    Private _BarCode As String
    Public Property BarCode() As String
        Get
            Return _BarCode
        End Get
        Set(ByVal value As String)
            _BarCode = value
        End Set
    End Property

    Private _IsActive As Boolean
    Public Property IsActive() As Boolean
        Get
            Return _IsActive
        End Get
        Set(ByVal value As Boolean)
            _IsActive = value
        End Set
    End Property

    Public Property ActiveLabel() As String
        Get
            If Me.IsActive Then
                Return "Active"
            Else
                Return "DeActive"
            End If
        End Get
        Set(ByVal value As String)
        End Set
    End Property

    Public Property ProductTypeLabel() As String
        Get
            If Me.ProductTypeID = 1 Then
                Return "Company"
            ElseIf Me.ProductTypeID = 2 Then
                Return "Market"
            ElseIf Me.ProductTypeID = 3 Then
                Return "Handmake"
            Else
                Return "Orther"
            End If
        End Get
        Set(ByVal value As String)
        End Set
    End Property

    Public Overrides Function ToString() As String
        Dim buf As String = Me.ID & ", " & Me.ProductName & ", " & Me.ProductDescription & ", " & Me.Price & ", " & Me.ProductTypeID & ", " & Me.CategoryGroupID & ", " & _
                            Me.CategoryID & ", " & Me.ProductCode & ", " & Me.BarCode & ", " & Me.IsActive
        buf &= MyBase.ToString()
        Return buf
    End Function

    Public Overloads Function compareAndGetDiff(ByVal _NewObj As Product) As String
        Dim buf As String = ""
        If Me.ProductName <> _NewObj.ProductName Then
            buf &= "ProductName=" & Me.ProductName & " -> " & _NewObj.ProductName & " "
        End If
        If Me.ProductDescription <> _NewObj.ProductDescription Then
            buf &= ", ProductDescription=" & Me.ProductDescription & " -> " & _NewObj.ProductDescription & " "
        End If
        If Me.Price <> _NewObj.Price Then
            buf &= ", Price=" & Me.Price & " -> " & _NewObj.Price & " "
        End If
        If Me.ProductTypeID <> _NewObj.ProductTypeID Then
            buf &= ", ProductTypeID=" & Me.ProductTypeID & " -> " & _NewObj.ProductTypeID & " "
        End If
        If Me.CategoryGroupID <> _NewObj.CategoryGroupID Then
            buf &= ", CategoryGroupID=" & CategoryGroupID & " -> " & _NewObj.CategoryGroupID & " "
        End If
        If Me.CategoryID <> _NewObj.CategoryID Then
            buf &= ", CategoryID=" & Me.CategoryID & " -> " & _NewObj.CategoryID & " "
        End If

        If Me.ProductCode <> _NewObj.ProductCode Then
            buf &= ", ProductCode=" & Me.ProductCode & " -> " & _NewObj.ProductCode & " "
        End If

        If Me.BarCode <> _NewObj.BarCode Then
            buf &= ", BarCode=" & Me.BarCode & " -> " & _NewObj.BarCode & " "
        End If

        If Me.IsActive <> _NewObj.IsActive Then
            buf &= ", IsActive=" & Me.IsActive & " -> " & _NewObj.IsActive & " "
        End If

        buf &= MyBase.compareAndGetDiff(_NewObj)
        Return buf
    End Function
End Class

